const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        nums:"",
        active_forze_love: "",
        active_forze_nums: "",
        active_forze_point: "",
        active_forze_times: "",
        froze: "",
        point:"0.00",
        froze_name:"",
        pointKey:"",
        imgPath: app.globalData.imgPath
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getData();
        if(options.froze_name && options.pointKey){
            this.setData({
                froze_name:options.froze_name,
                pointKey:options.pointKey,
            });
        }
        wx.setNavigationBarTitle({
            title: options.froze_name+'激活',
        });
        
    },
    getData() {
        let urlStr = app.getNetAddresss("plugin.love.Frontend.Modules.Love.Controllers.active-froze.index");
        app._getNetWork({
          url: urlStr,
          success: (resdata) => {
            let res = resdata.data;
            if (res.result != 1) return;
            this.setData({
                active_forze_love : res.data.active_forze_love,
                active_forze_nums : res.data.active_forze_nums,
                active_forze_point : res.data.active_forze_point,
                active_forze_times : res.data.active_forze_times,
                froze: res.data.froze
            });
          },
        });
    },
    activeLoveFroze() {
        let urlStr = app.getNetAddresss("plugin.love.Frontend.Modules.Love.Controllers.active-froze.active");
        app._getNetWork({
          url: urlStr,
          data: {
            nums: this.data.nums
          },
          success: (resdata) => {
            let res = resdata.data;
            if(res.result) {
                wx.showToast({
                    title: res.msg,
                    icon: "none",
                    icon:"success"
                });
            }else {
                wx.showToast({
                    title: res.msg,
                    icon: "none",
                    icon:"fail"
                });
            }
          },
        });
    },
    onChange(e) {
        let value =  Number(this.data.active_forze_point) / Number(this.data.active_forze_love);
        this.setData({
            nums:e.detail,
            point:(Number(e.detail) * value).toFixed(2)
        })  
    }
})